package com.usian.ai.controller;

import com.alibaba.fastjson2.JSON;
import com.usian.ai.common.Result;
import com.usian.ai.common.vo.CandidateReqVo;
import com.usian.ai.common.vo.CandidateSaveReqVo;
import com.usian.ai.service.CandidateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * restFul:
 * 1.get请求 查询，请求参数在url中 /order/get?name=123&age=18
 * 2.post请求 添加，请求参数在body中  {}
 * 3.put请求 修改，请求参数在body中  {}
 * 4.delete请求 删除，请求参数在url中 /order/delete?id=18
 *
 * 特殊情况：
 * 1：添加，修改：POST     PUT
 * 2：删除 ：DELETE GET
 * 3：多条件查询  POST  {}
 * 4:占位符：{id}     order?id=1 order/1
 *
 *
 *
 *
 *
 * @TODO:
 * @Author:baimu
 * @Date:2024 12 05 09 49
 **/
@RestController
@RequestMapping("/candidate")
@Slf4j

@CrossOrigin
public class CandidateController {

    @Autowired
    CandidateService candidateService;



    @PostMapping("/list")
    public Result list(@RequestBody CandidateReqVo candidateReqVo){
        log.info("查询参数："+ JSON.toJSONString(candidateReqVo));
        return candidateService.list(candidateReqVo);

    }


    @PostMapping("/add")
    public Result add(@Validated @RequestBody CandidateSaveReqVo candidateSaveReqVo){
        log.info("添加参数："+ JSON.toJSONString(candidateSaveReqVo));

        return candidateService.add(candidateSaveReqVo);
    }


}
